#pragma once

#include <algorithm>
#include <list>
#include <map>
#include <mutex>
#include <string>

#include "bondlib.h"

class S_BONDLIB_EXPORT QBPROVINCEINFO {
 public:
  QBPROVINCEINFO();
  QBPROVINCEINFO(const QBPROVINCEINFO& rhs);
  ~QBPROVINCEINFO();
  QBPROVINCEINFO& operator=(const QBPROVINCEINFO& bi);

  char Area_Code[16 + 1];   // 区域代码
  char* Area_Name;          // 区域中文名称
  char* Area_English_Name;  // 区域英文文名称
  char Area_Level[16 + 1];
  char Area_Upper_Grade_Code[16 + 1];
  void SetAreaName(const char* name);
  void SetAreaEnglishName(const char* name);

 private:
  static char Empty;
};

class S_BONDLIB_EXPORT CQBProvinceInfo {
 public:
  static CQBProvinceInfo& instance();

 public:
  std::map<std::string, QBPROVINCEINFO>& GetAllProviceInfo() { return m_map; }

  const QBPROVINCEINFO* GetProviceInfo(const std::string& id);

  bool Add(QBPROVINCEINFO& info);
  bool Clear();

 public:
  void DumpStatus(int mode = 0) const;

 private:
  CQBProvinceInfo();
  virtual ~CQBProvinceInfo();

 protected:
  std::map<std::string, QBPROVINCEINFO> m_map;
  std::mutex m_mutex;
};
